package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicSkReturnItemDAO;
import com.cssy.yd.logic.entity.LogicSkReturnItemDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-08-21
 */
public class LogicSkReturnItemDAOImpl extends SqlMapClientDaoSupport implements LogicSkReturnItemDAO {

    /**
     * 插入数据
     * @param logicSkReturnItemDO
     * @return 插入数据的主键
     */
    public String insertLogicSkReturnItemDO(LogicSkReturnItemDO logicSkReturnItemDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicSkReturnItem.insert", logicSkReturnItemDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicSkReturnItemDO
     * @return 查出的记录数
     */
    public Integer countLogicSkReturnItemDOByExample(LogicSkReturnItemDO logicSkReturnItemDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicSkReturnItem.countByDOExample", logicSkReturnItemDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicSkReturnItemDO
     * @return 受影响的行数
     */
    public Integer updateLogicSkReturnItemDO(LogicSkReturnItemDO logicSkReturnItemDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicSkReturnItem.update", logicSkReturnItemDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicSkReturnItemDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicSkReturnItemDO> findListByExample(LogicSkReturnItemDO logicSkReturnItemDO) throws DataAccessException {
        List<LogicSkReturnItemDO> list = getSqlMapClientTemplate().queryForList("LogicSkReturnItem.findListByDO", logicSkReturnItemDO);
        return list;
    }

    /**
     * 根据主键获取logicSkReturnItemDO
     * @param id
     * @return logicSkReturnItemDO
     */
    public LogicSkReturnItemDO findLogicSkReturnItemDOByPrimaryKey(String id) throws DataAccessException {
        LogicSkReturnItemDO logicSkReturnItemDO = (LogicSkReturnItemDO) getSqlMapClientTemplate().queryForObject("LogicSkReturnItem.findByPrimaryKey", id);
        return logicSkReturnItemDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicSkReturnItemDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicSkReturnItem.deleteByPrimaryKey", id);
        return rows;
    }

    @SuppressWarnings("unchecked")
	@Override
   	public List<LogicSkReturnItemDO> find(SearchConditions scs)
   			throws DataAccessException {
   		List<LogicSkReturnItemDO> list = getSqlMapClientTemplate().queryForList("LogicSkReturnItem_ex.find", scs);
   		   return list;
   	}

   	@Override
   	public Integer count(SearchConditions scs) throws DataAccessException {		
   		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicSkReturnItem_ex.count", scs);
   	      return count;
   	}

	@SuppressWarnings("unchecked")
	@Override
	public List<LogicSkReturnItemDO> finditembytkid(String tkid) throws DataAccessException  {
		 List<LogicSkReturnItemDO> list = getSqlMapClientTemplate().queryForList("LogicSkReturnItem_ex.findbytkid", tkid);
	        return list;
	}
}